package com.ruoyi.hr.service.impl.salaryadmin.salaryinfo;

import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.hr.domain.Authority;
import com.ruoyi.hr.mapper.AuthorityMapper;
import com.ruoyi.hr.mapper.salaryadmin.SalaryAdminMapper;
import com.ruoyi.hr.mapper.salaryadmin.salaryinfo.SalaryInfoPayEmpMapper;
import com.ruoyi.hr.service.salaryadmin.salaryinfo.SalaryInfoPayEmpService;
import com.ruoyi.system.domain.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Service
public class SalaryInfoPayEmpServiceImpl implements SalaryInfoPayEmpService {

    @Autowired
    SalaryInfoPayEmpMapper salaryInfoPayEmpMapper;

    @Autowired
    SalaryAdminMapper salaryAdminMapper;

    @Autowired
    AuthorityMapper authorityMapper;

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public List<Map<String, Object>> findData(Map map, List<Authority> authorities, int isAdmin) {
        List<String> proList = new ArrayList<String>();
        proList = salaryAdminMapper.findProByPgid(map.get("pgid").toString());
        map.put("pro", proList);
        return salaryInfoPayEmpMapper.findData(map, authorities, isAdmin);
    }

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int changeHangUp(Map map) {
        return salaryInfoPayEmpMapper.changeHangUp(map);
    }

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int update(Map map) {
        return salaryInfoPayEmpMapper.update(map);
    }
}